package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"webhookadapter/app"
	"webhookadapter/internal"
	"webhookadapter/middleware"
)

func main() {
	internal.InitConfig()
	internal.InitLogger()
	gin.DisableConsoleColor()
	gin.SetMode(internal.AppConfig.Server.GinMode)
	server := gin.Default()
	server.Use(middleware.LoggerToFile())
	app.InitRouter(server)
	err := server.Run(":" + internal.AppConfig.Server.Port)
	if err != nil {
		panic(fmt.Errorf("fatal to start a web server: %w", err))
	}
}
